local piaoyong = fk.CreateSkill{
  name = "wk_heg__piaoyong",
  tags = {
    Skill.Compulsory
  }
}

Fk:loadTranslationTable{
  ["wk_heg__piaoyong"] = "朴勇",
  [":wk_heg__piaoyong"] = "锁定技，当你于回合内使用：首张牌时，你观看一名其他角色所有手牌；第三张牌时，你弃置一名其他角色的一张手牌。",
  ["#wk_heg__piaoyong_choose2discard"] = "朴勇：选择一名其他角色，弃置其一张手牌",
  ["#wk_heg__piaoyong_choose2view"] = "朴勇：选择一名其他角色，观看其所有手牌",
  ["#wk_heg__piaoyong_discard"] = "朴勇：弃置 %dest 一张牌",
}

piaoyong:addEffect(fk.CardUsing, {
  anim_type = "control",
  can_trigger = function (self, event, target, player, data)
    local use_card_times = #player.room.logic:getEventsOfScope(GameEvent.UseCard, 999, function (e)
      return e.data.from == player
    end,Player.HistoryTurn)
    event:setCostData(self, {times = use_card_times})
    return player:hasSkill(self) and target == player and (use_card_times == 1 or use_card_times == 3) and player.room.current == player
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local cost_data = event:getCostData(self)
    if cost_data.times == 1 then
      local others = room:getOtherPlayers(player)
      if #others == 0 then return end
      local tos = room:askToChoosePlayers(player, {
        targets = others,
        min_num = 1, max_num = 1,
        prompt = "#wk_heg__piaoyong_choose2view",
        skill_name = piaoyong.name,
        cancelable = false})
      local t = tos[1]
      room:viewCards(player,{
        cards = t:getCardIds("h"),
        skill_name = piaoyong.name
      })
    else
      local others = table.filter(room:getOtherPlayers(player), function (p)
        return not p:isKongcheng()
      end)
      if #others == 0 then return end
      local tos = room:askToChoosePlayers(player,{
        targets = others,
        min_num = 1, max_num = 1,
        prompt = "#wk_heg__piaoyong_choose2discard", 
        skill_name = piaoyong.name,
        cancelable = false
      })
      local t = tos[1]
      local card = room:askToChooseCard(player,{
        target = t,
        flag = "h",
        skill_name = piaoyong.name, 
        prompt = "#wk_heg__piaoyong_discard::"..t.id})
      room:throwCard(card, piaoyong.name, t, player)
    end
  end,
})

return piaoyong